$(document).ready(function(){
	$.ajax({
		url:"../studentTestList",
		type:"post",
		data:{},
		async: false,
		success:function(res){
			for(var i=1;i<=res.count;i++){
				
				$.ajax({
					url:"htmlPart/testCard.html",
					type:"post",
					data:{},
					async: false,
					success:function(code){
						$("#testCards").append(code);
						$("#testName").attr("id","testName"+res["testId"+i]);
						$("#"+"testName"+res["testId"+i]).html("试题名称 :"+res["testName"+i]);
						$("#operaterName").attr("id","operaterName"+res["testId"+i]);
						$("#"+"operaterName"+res["testId"+i]).html("来自老师   "+res["operaterName"+i]);
						$("#cardStyle").attr("id","cardStyle"+res["testId"+i]);
						$("#lookingBtn").attr("id","lookingBtn"+res["testId"+i]);
						$("#badge").attr("id","badge"+res["testId"+i]);
					}
				});
				
				if(res["isFinished"+i]==1){
					$("#"+"cardStyle"+res["testId"+i]).attr("class","card border-left-success shadow h-100 py-2");
					$("#"+"lookingBtn"+res["testId"+i]).attr("href","viewFinishedTest.jsp?test_id="+res["testId"+i]);
					$("#"+"lookingBtn"+res["testId"+i]).val("查看");
					$("#"+"badge"+res["testId"+i]).html("已完成");
				}else if(res["isFinished"+i]==0){
					$("#"+"cardStyle"+res["testId"+i]).attr("class","card border-left-danger shadow h-100 py-2");
					$("#"+"lookingBtn"+res["testId"+i]).attr("href","finishTest.jsp?test_id="+res["testId"+i]);
					$("#"+"lookingBtn"+res["testId"+i]).attr("class","btn btn-warning");
					$("#"+"lookingBtn"+res["testId"+i]).html("开始做题");
					$("#"+"badge"+res["testId"+i]).html("未完成");
				}	
			}
		}
	});
	
})